package com.xgx.distqcp.Controller;

import com.jfinal.captcha.CaptchaRender;
import com.xgx.distqcp.Common.ImageHelper;
import com.xgx.distqcp.Render.ImageRender;
import io.jboot.web.controller.JbootController;
import io.jboot.web.controller.annotation.RequestMapping;
import pub.greenbamboo.captcha.*;

import javax.imageio.ImageIO;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.awt.image.ImageObserver;
import java.io.IOException;
import java.io.PrintWriter;

@RequestMapping("/capcha")
public class CapchaController extends JbootController {

    public void index() throws IOException {
       CaptchaContext codeerContext = new CaptchaContext (CaptchaTypeEnum.ACaptcha);
       ImageCode imageCode= codeerContext.getImageCode();
       Image img= imageCode.getImage();
       render(new ImageRender(img));
    }
}
